export default {
	precision(money) {
		var precision = localStorage.getItem('precision');
		return (money / 1).toFixed(precision).toString().replace(/\d+/, function (n) {
			return n.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
		});
	},
	precision_basic(money) {
		var precision = localStorage.getItem('precision_basic');
		return (money / 1).toFixed(precision).toString().replace(/\d+/, function (n) {
			return n.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
		});
	},
	currency() {
		return localStorage.getItem('currency');
	},
	currency_symbol_basic() {
		return localStorage.getItem('currency_symbol_basic');
	}, 
	// 数字转为科学计数法  1,000.0125
	toThousands(num = 0) {
		return num.toString().replace(/\d+/, function (n) {
			return n.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
		});
	},
	// 将日期格式化为yyyy-MM-dd HH:mm:ss格式
	formatDate(datestr) {
		var date = new Date(datestr);
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var day = date.getDate();
		var hour = date.getHours();
		console.log(hour);
		var minute = date.getMinutes();
		var second = date.getSeconds();
		var ext = ' AM';
		if (month < 10) month = "0" + month;
		if (day < 10) day = "0" + day;
		if(hour>13) {
			hour = hour-12;
			ext = ' PM'
		}
		if (hour < 10) hour = "0" + hour;
		if (minute < 10) minute = "0" + minute;
		if (second < 10) second = "0" + second;
		return month + "/" + day + "/" + year + " " + hour + ":" + minute + ":" + second+ext;
	}
}
